var wwwroot = "http://localhost:8080/aaarrgh/";

function cuenta() {
	var countActualCharacters = $('#txtTwitt').val().length;
	var countRemainingCharacters = eval(140 - countActualCharacters); 
	$('#caracteresRestantes').html('Restan ' + countRemainingCharacters + ' caracteres');
}

function tweetValidate(){
	if($('#txtTwitt').val().length == 0){
		alert('Escribi un mensaje para enviar!');
		return false;
	}
}

function newResponse(tweetAuthor,tweetID){
	var message = "@"+tweetAuthor+" ";
	message += prompt("Responder a "+tweetAuthor,"");
	
	if(message != "@"+tweetAuthor+" " && message.length<=140){
		$.ajax({
		  data : "message="+message,
		  type : "GET",
		  url : wwwroot + "tweetResponse?tweetID="+tweetID+"&txtTwitt="+message, //Llama a tweetResponse
		  success : function(data) {location.reload();}
		 });	
	}else{
		if(message != "@"+tweetAuthor+" "){
			alert("Escribi un mensaje para enviar!");
		}
		else
			alert("El mensaje es muy largo!");
		location.reload();
	}
}

function changeTab(tabId, tabNavItem){
	$('.tabContent').slideUp("fast");
	$('#' + tabId).slideDown("slow");
	$('.tabNav ul li').removeClass('selectedLi');
	$('.tabNav ul li a').removeClass('selectedA');
	$('#' + tabNavItem).addClass('selectedA');
	$('#' + tabNavItem).parent().addClass('selectedLi');
}

$(document).ready(function(){
	$('#btnEditProfile').click(function(){
		$("#formEditProfile").show();
	});
});


function openWindow(url){
	var left = ($(window).width() / 2) - 250;
	var top = ($(window).height() / 2) - 175;
	window.open(url, 'Editar mi Perfil', 'resizable=0,scrollbars=0,titlebar=0,location=0,width=500,height=350,left=' + left + 'px,top=' + top + 'px',false);
}

function viewConversation(tweetID){
	openWindow('../pages/conversations.jsp?tweetID='+tweetID);
}